package com.demo;

import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;

public class Producer {
    public static void main(String[] args) {
        try {
            produce("hello");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void produce(String message) throws Exception {
        Socket socket = new Socket(InetAddress.getLocalHost(), BrokerServer.SERVICE_PORT);
        try (
                PrintWriter out = new PrintWriter(socket.getOutputStream())
        ) {
            out.println(message);
            out.flush();
        }
    }
}
